﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using pc_system.Model;
namespace pc_system.View
{
    public partial class CheckStock : Form
    {
        private dbEntities _db;
        public CheckStock()
        {
            InitializeComponent();
            ChangeComponent();
            _db = new dbEntities();
            this.vProductInfoBindingSource.DataSource = _db.vProductInfo;
            this.返回按钮.Click += checkStock_returnButton;
           
            this.checkstock_search.Click += checkStock_searchButton;
            
        }

        #region 库存查看返回按钮
        private void checkStock_returnButton(object sender, EventArgs e)
        {
            this.Close();

        }
        #endregion

        #region 搜索按钮功能
        private void checkStock_searchButton(object sender, EventArgs e)
        {
            this.vProductInfoBindingSource.DataSource = _db.vProductInfo.Where(c =>
                c.product_code.Contains(checkstock_text.Text) ||
                c.product_code == checkstock_text.Text);
        }

        #endregion


        #region 快捷键
        //重写处理命令键方法以监听快捷键
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                //System.Windows.Forms.SendKeys.Send("{F5}");
                this.Close();
                return base.ProcessCmdKey(ref msg, keyData);
            }

            if (keyData == Keys.Enter)
            {
                //System.Windows.Forms.SendKeys.Send("{F5}");
                this.checkstock_search.PerformClick();
                return base.ProcessCmdKey(ref msg, keyData);
            }

            //继续原来base.ProcessCmdKey中的处理
            return base.ProcessCmdKey(ref msg, keyData);
        }


        #endregion


        private void textbox_MouseClick(object sender, MouseEventArgs e)
        {
            TextBox tb = (TextBox)sender;
            tb.SelectAll();
        }


       


       
       

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
